﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.WebPages.Html;

/***
*机器名：BDXYIT-HUI
*项目名称：$projectname$
*命名空间：bdxyit.com.RecruitmentAppSys.Helpers
*文件名：HtmlHelpers
*系统时间：3/30/2012 5:32:36 PM
*当前用户：huihui
*创建时间：2012
*
*修改时间：2012 3/30/2012 5:32:36 PM
*修改事件：
***/

namespace bdxyit.com.RecruitmentAppSys.Helpers
{
    public static class HtmlHelpers
    {
        /// <summary>
        /// 截取较长的字符串的方法
        /// </summary>
        /// <param name="helper">帮助器</param>
        /// <param name="input">字符串</param>
        /// <param name="length">长度</param>
        /// <returns>截取后的</returns>
        public static string Truncate(this HtmlHelper helper, string input, int length)
        {
            if (input.Length <= length)
            {
                return input;
            }
            else
            {
                return input.Substring(0, length) + "……";
            }
        }

        /// <summary>
        /// Html编码
        /// </summary>
        /// <param name="input">要进行编辑的字符串</param>
        /// <returns>Html编码后的字符串</returns>
        public static string HtmlSpecialEntitiesEncode(string input)
        {
            return HttpUtility.HtmlEncode(input);
        }

        /// <summary>
        /// Html解码
        /// </summary>
        /// <param name="input">要进行解码的字符串</param>
        /// <returns>解码后的字符串</returns>
        public static string HtmlSpecialEntitiesDecode(string input)
        {

            return HttpUtility.HtmlDecode(input);
        }
    }
}